package com.zenika.zentracker.spring;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTransactionManager;

import com.zenika.zentracker.hibernate.ZenTrackerSessionFactory;

public class ZenTrackerHibernateTransactionManager extends HibernateTransactionManager {

    /**
     * The Transaction Manager need to use the real SessionFactory as it is the SessionFactor instance that is used as a key for the SessionHolder.
     * 
     * Because it is impossible to subclass the Hibernate SessionFactory, the real SessionFactory is used by the SessionContext to retrieve the Session from
     * the current Thread/Tx
     */
    public SessionFactory getSessionFactory() {
        return ((ZenTrackerSessionFactory) super.getSessionFactory()).getSessionFactory();
    }
    
}
